﻿<?php include $this->admin_tpl('meta');?>
<title>基础</title>
</head>
<body>
<div class="page-container" style="padding-bottom:0;">
	<form id="search">
		<input type="hidden" value="" name="field">
		<input type="hidden" value="" name="order">
		<input type="text" name="supplier_name" class="input-text search" placeholder="供应商名称" autocomplete="off">
		<input type="text" name="code" class="input-text search" placeholder="供应商编码" autocomplete="off">
		<input type="text" name="remark" class="input-text search" placeholder="备注" autocomplete="off">
		<span class="select-box inline">
			<select name="status" class="select">
			<option value="">是否启用</option>
			<option value="0">启用</option>
			<option value="1">禁用</option>
			</select>
		</span>
		<a class="btn btn-success radius" href="javascript:void(0)" id="btn_search"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</a>
		<button class="btn btn-primary radius" id="btn_reset" type="reset"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</button>
	</form>
	
	<table id="table" class="mt-20" lay-filter="table"></table>
</div>

<script type="text/html" id="tool_temp">
	<a href="javascript:;" onclick="yzm_open('添加店铺','<?php echo U('collect_shop',['type'=>'add']);?>','800','640')" class="btn btn-primary radius"><i class="yzm-iconfont yzm-icontianjia"></i> 添加店铺</a>
	<a href="javascript:;" id="btn_del" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a>
</script>
<script type="text/html" id="op_temp">
	<a class="layui-btn layui-btn-yzm layui-btn-xs" onclick="yzm_open('添加店铺','<?php echo U('collect_shop',['type'=>'add']);?>?id={{= d.id}}','800','630')" lay-event="detail" style="text-decoration:none;">编辑</a>
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete" style="text-decoration:none;">删除</a>
</script>
<script type="text/html" id="platform_temp">
  <button class="layui-btn layui-btn-primary dropdown-platform" style="height:28px;width:90px;padding:0 10px;">
    <span>{{= d.platform}}</span>
    <i class="layui-icon layui-icon-down layui-font-12" style="vertical-align: center;"></i>
  </button>
</script>

<script type="text/html" id="shop_status_temp">
  <button class="layui-btn layui-btn-primary dropdown-status" style="height:28px;width:90px;padding:0 10px;">
    <span>{{= d.shop_status}}</span>
    <i class="layui-icon layui-icon-down layui-font-12" style="vertical-align: center;"></i>
  </button>
</script>

<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/layui/layui.js"></script>

<script>

layui.use(function(){ //亦可加载特定模块：layui.use(['layer', 'laydate', function(){
	table = layui.table; //表格
	util = layui.util; //工具集
	dropdown = layui.dropdown; //下拉菜单
	form = layui.form;
	//执行一个 table 实例
	option = {
		elem: '#table',
		height: 'full-80',
		limit:30,
		limits:[30,60,90],
		url:'<?php echo U('collect_shop');?>',
		where: $('#search').serializeJson(),
		title: '店铺列表',
		autoSort: false,
		page: {theme:'#409eff',groups:3,hash:true}, //开启分页
		toolbar: $('#tool_temp').html(), //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
		cols: [[ //表头
			{type: 'checkbox', fixed: 'left'},
			{field: 'id', title: 'ID', width:80,align:'center'},
			{field: 'shop_name', title: '店铺名称', width:200,align:'left', edit:true},
			{field: 'platform', title: '电商平台',align:'center', templet:'#platform_temp'},
			{field: 'remark', title: '备注', edit:true},
			{field: 'is_own', title: '是否自营',align:'center',templet:function(row){
				if(row.is_own == 1){
					return '<span class="yzm-status-enable" data-field="is_own" data-text="自营|分销" data-db="collect_shop" data-id="'+row.id+'" onclick="yzm_change_status(this,\'public_change_status\')"><i class="yzm-iconfont">&#xe81f;</i>自营</span>';
				}else{
					return '<span class="yzm-status-disable" data-field="is_own" data-text="自营|分销" data-db="collect_shop" data-id="'+row.id+'" onclick="yzm_change_status(this,\'public_change_status\')"><i class="yzm-iconfont">&#xe601;</i>分销</span>';
				}
			}},
			{field: 'shop_status', title: '店铺状态',align:'center', sort: true, templet:'#shop_status_temp'},
			{field: 'auth_expire', title: '授权到期',align:'center', sort: true, width:200,templet: function(row) {return util.toDateString(row.auth_expire*1000, 'yyyy-MM-dd');}},
			{field: 'adminids', title: '管理员', width: 150,align:'left', width:200,templet:function(row){
				var admin = row.adminids.split(',');
				var html = '';
				$.each(admin, function(index, value) {
					html += '<span class="label label-primary radius ml-5">'+value+'</span>';
				});
				return html;
			}},
			{field: 'add_time', title: '添加时间',align:'center', sort: true, width:200,templet: function(row) {return util.toDateString(row.add_time*1000);}},
			{fixed: 'right', title: '操作', width: 200, align:'center', toolbar: '#op_temp'}
		]],
		done:function(res,curr,count){
			var options = this;
			public_table();
			select_table(options,<?php echo json_encode($platform_arr);?>,'.dropdown-platform','collect_shop','platform');
			select_table(options,<?php echo json_encode($shop_status_arr);?>,'.dropdown-status','collect_shop','shop_status');
		}
	};	
	table.render(option);
	init_table('collect_shop');
})


	
</script>


</body>
</html>